<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class RsReportAuth extends Model
{
    use HasFactory;
    public $timestamps=false;
    protected $table='rs_report_auth';

    //对数据进行添加/修改
    public static function creates($data){
        if(!$data['id']){
            $model=new self();
            $model->user_id=$data['user_id'];

            $model->remark=$data['remark'];
        }else{
            $model=self::query()->where(['id'=>$data['id']])->first();
            $model->user_id=$data['user_id'];

            $model->remark=$data['remark'];
        }
        return $model->save() ?true:false;
    }


    public function getUser(){
        return $this->hasOne(User::class,'id','user_id');
    }

    public function getRsUser(){
        return $this->hasOne(RsUsers::class,'user_id','user_id');
    }

    public function report()
    {
        return $this->hasOne(RsReport::class,'id','report_id');
    }
}
